<?php
    include($_SERVER['DOCUMENT_ROOT']."/ObstacleWebApp/view/headeradmin.php");
?>

<section>
    
        
    
    <?php
    
        $query1 = "SELECT * FROM patient WHERE Id = ".$_GET['id']."";
        $result1 = mysql_query($query1) or die (mysql_error());
        while ($row1 = mysql_fetch_array($result1))
        {
            echo "<hgroup><h1>".$row1['FirstName']." ".$row1['LastName']."</h1></hgroup>";
            echo "<br><table>";
            
            if ($row1['Gender'] == "V")
            {
                echo "<tr><td><span style=\"font-weight: bold\">Geslacht: </span></td><td>Vrouw</td></tr>";
            }
            else
            {
                echo "<tr><td><span style=\"font-weight: bold\">Geslacht: </span></td><td>Man</td></tr>";
            }
            
            $dayofbirth = date("d-m-Y",strtotime($row1['DayOfBirth']));
            echo "<tr><td><span style=\"font-weight: bold\">Geboortedatum: </span></td><td>".$dayofbirth."</td></tr>";
            
            $query2 = "SELECT * FROM building where Id=".$row1['BuildingId']."";
            $result2 = mysql_query($query2) or die (mysql_error());
            while($row2 = mysql_fetch_array($result2))
            {
                echo "<tr><td><span style=\"font-weight: bold\">Adres: </span></td><td>".$row2['Street']." ".$row2['Number']." (<a href=\" ".$cfg['basepath']."controller/gebouw/gebouwdetail.php?id=".$row1['BuildingId']."\" >Bekijk gebouw-details)</a></td></tr>";
            }
            
            $query3 = "SELECT * FROM maritalstatus where Id=".$row1['MaritalStatus']."";
            $result3 = mysql_query($query3) or die (mysql_error());
            while($row3 = mysql_fetch_array($result3))
            {
                echo "<tr><td><span style=\"font-weight: bold\">Burgerlijke status: </span></td><td>".$row3['Name']."</td></tr>";
            }
            
            echo "<tr><td><span style=\"font-weight: bold\">Gewicht: </span></td><td>".$row1['Weight']." kg</td></tr>";
            
            echo "<tr><td><span style=\"font-weight: bold\">Lengte: </span></td><td>".$row1['Length']." cm</td></tr>";
            
            echo "<tr><td><span style=\"font-weight: bold\">Telefoonnummer: </span></td><td>".$row1['TelNumber']."</td></tr>";
            
            echo "<tr><td><span style=\"font-weight: bold\">Email-adres: </span></td><td>".$row1['Email']."</td></tr>";
            
            echo "<tr><td><span style=\"font-weight: bold\">Contactpersoon: </span></td><td>".$row1['ContactFirstName']." ".$row1['ContactLastName']."</td></tr>";
            
            echo "<tr><td><span style=\"font-weight: bold\">Relatie contactperson t.o.v. bewoner: </span></td><td>".$row1['ContactRelation']."</td></tr>";
            
            echo "<tr><td><span style=\"font-weight: bold\">Telefoonnummer contactpersoon: </span></td><td>".$row1['ContactTelNumber']."</td></tr>";
            
            echo "<tr><td><span style=\"font-weight: bold\">Email-adres contactpersoon: </span></td><td>".$row1['ContactEmail']."</td></tr>";
            
            $query5 = "SELECT * FROM patientuser WHERE PatientId = ".$row1['Id']."";
            $result5 = mysql_query($query5) or die (mysql_error());
            while ($row5 = mysql_fetch_array($result5))
            {
                $userId = $row5['UserId'];
            }
            
            $query7 = "SELECT * FROM user WHERE Id = ".$userId."";
            $result7 = mysql_query($query7) or die (mysql_error());
            while ($row7 = mysql_fetch_array($result7))
            {
                echo "<tr><td><span style=\"font-weight: bold\">Toegewezen aan zorgprofessional: </span></td><td>".$row7['FirstName']." ".$row7['LastName']."</td></tr>";
            }
            
            
            
            $query6 = "SELECT * FROM patientusedaid WHERE PatientId=".$row1['Id']."";
            $result6 = mysql_query($query6) or die (mysql_error());
            while($row6 = mysql_fetch_array($result6))
            {
                $query7 = "SELECT * FROM usedaid WHERE Id=".$row6['UsedAidId']." AND Id>0";
                $result7 = mysql_query($query7) or die (mysql_error());
                while($row7 = mysql_fetch_array($result7))
                {
                    echo "<tr><td><span style=\"font-weight: bold\">Loop-hulpmiddel: </span></td><td>".$row7['Name']."</td></tr>";
                }
            }
            
            $query8 = "SELECT * FROM patientmovementrestriction WHERE PatientId=".$row1['Id']."";
            $result8 = mysql_query($query8) or die (mysql_error());
            while($row8 = mysql_fetch_array($result8))
            {
                $query9 = "SELECT * FROM movementrestriction WHERE Id=".$row8['MovementRestrictionId']."";
                $result9 = mysql_query($query9) or die (mysql_error());
                while($row9 = mysql_fetch_array($result9))
                {
                    //geen rijen
                    $query10 = "SELECT * FROM patientusedaid WHERE Id=".$row8['PatientUsedAidId']."";
                    $result10 = mysql_query($query10) or die (mysql_error());
                    while($row10 = mysql_fetch_array($result10))
                    {
                        $query11 = "SELECT * FROM usedaid WHERE Id=".$row10['UsedAidId']."";
                        $result11 = mysql_query($query11) or die (mysql_error());
                        while($row11 = mysql_fetch_array($result11))
                        {
                            if ($row8['Value'] == 1)
                            {
                                echo "<tr><td><span style=\"font-weight: bold\">".$row9['MRKey'].": </span></td><td>";
                                echo "<input disabled name=\"mv".$row9['Id']."\" type=\"radio\" class=\"star\" value=\"1\" title=\"1\" checked/>";
                                echo "<input disabled name=\"mv".$row9['Id']."\" type=\"radio\" class=\"star\" value=\"2\" title=\"2\"/>";
                                echo "<input disabled name=\"mv".$row9['Id']."\" type=\"radio\" class=\"star\" value=\"3\" title=\"3\"/>";
                                echo "<input disabled name=\"mv".$row9['Id']."\" type=\"radio\" class=\"star\" value=\"4\" title=\"4\"/>";
                                echo " (hulpmiddel: ".$row11['Name'].")</td></tr>";
                            }
                            elseif ($row8['Value'] == 2) 
                            {
                                echo "<tr><td><span style=\"font-weight: bold\">".$row9['MRKey'].": </span></td><td>";
                                echo "<input disabled name=\"mv".$row9['Id']."\" type=\"radio\" class=\"star\" value=\"1\" title=\"1\"/>";
                                echo "<input disabled name=\"mv".$row9['Id']."\" type=\"radio\" class=\"star\" value=\"2\" title=\"2\" checked/>";
                                echo "<input disabled name=\"mv".$row9['Id']."\" type=\"radio\" class=\"star\" value=\"3\" title=\"3\"/>";
                                echo "<input disabled name=\"mv".$row9['Id']."\" type=\"radio\" class=\"star\" value=\"4\" title=\"4\"/>";
                                echo " (hulpmiddel: ".$row11['Name'].")</td></tr>";
                            }
                            elseif ($row8['Value'] == 3) 
                            {
                                echo "<tr><td><span style=\"font-weight: bold\">".$row9['MRKey'].": </span></td><td>";
                                echo "<input disabled name=\"mv".$row9['Id']."\" type=\"radio\" class=\"star\" value=\"1\" title=\"1\"/>";
                                echo "<input disabled name=\"mv".$row9['Id']."\" type=\"radio\" class=\"star\" value=\"2\" title=\"2\"/>";
                                echo "<input disabled name=\"mv".$row9['Id']."\" type=\"radio\" class=\"star\" value=\"3\" title=\"3\" checked/>";
                                echo "<input disabled name=\"mv".$row9['Id']."\" type=\"radio\" class=\"star\" value=\"4\" title=\"4\"/>";
                                echo " (hulpmiddel: ".$row11['Name'].")</td></tr>";
                            }
                            elseif ($row8['Value'] == 4)
                            {
                                echo "<tr><td><span style=\"font-weight: bold\">".$row9['MRKey'].": </span></td><td>";
                                echo "<input disabled name=\"mv".$row9['Id']."\" type=\"radio\" class=\"star\" value=\"1\" title=\"1\"/>";
                                echo "<input disabled name=\"mv".$row9['Id']."\" type=\"radio\" class=\"star\" value=\"2\" title=\"2\"/>";
                                echo "<input disabled name=\"mv".$row9['Id']."\" type=\"radio\" class=\"star\" value=\"3\" title=\"3\"/>";
                                echo "<input disabled name=\"mv".$row9['Id']."\" type=\"radio\" class=\"star\" value=\"4\" title=\"4\" checked/>";
                                echo " (hulpmiddel: ".$row11['Name'].")</td></tr>";
                            }
                        }
                    }
                }
            }
            
            $query4 = "SELECT * FROM patientspec where Activated='T'";
            $result4 = mysql_query($query4) or die (mysql_error());
            while($row4 = mysql_fetch_array($result4))
            {
                $query5 = "SELECT * FROM patientdetail where PatientId = ".$_GET['id']." AND PatientSpecId = ".$row4['Id']."";
                $result5 = mysql_query($query5) or die (mysql_error());
                while($row5 = mysql_fetch_array($result5))
                {
                    echo "<tr><td><span style=\"font-weight: bold\">".$row4['PatientKey'].":</span></td><td> ".$row5['Value']."</td></tr>";
                }
            }
        }
    
    ?>
    </table>
        <br>
<input type="button" value="Terug" onclick="javascript:history.back();" />



</section>

<?php
    include($_SERVER['DOCUMENT_ROOT']."/ObstacleWebApp/view/footer.php");
?>